package pro.chenggang.project.reactive.mybatis.support.r2dbc.spring.application.mapper;

import org.apache.ibatis.annotations.Mapper;
import pro.chenggang.project.reactive.mybatis.support.r2dbc.spring.application.entity.extend.DeptWithEmp;
import pro.chenggang.project.reactive.mybatis.support.r2dbc.spring.application.entity.model.Dept;
import pro.chenggang.project.reactive.mybatis.support.r2dbc.spring.application.mapper.dynamic.DeptDynamicMapper;
import pro.chenggang.project.reactive.mybatis.support.r2dbc.spring.application.mapper.dynamic.DeptDynamicSqlSupport;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.LocalDateTime;

import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;

/**
 * auto generated
 * @author AutoGenerated
 */
@Mapper
public interface DeptMapper extends DeptDynamicMapper {

    default Mono<Long> count(){
        return count(dsl -> dsl);
    }

    default Flux<Dept> selectAll(){
        return select(dsl -> dsl);
    }

    default Mono<Dept> selectOneByDeptNo(Long deptNo){
        return selectOne(dsl -> dsl
                .where(DeptDynamicSqlSupport.deptNo,isEqualTo(deptNo))
        );
    }

    default Flux<Dept> selectListByTime(LocalDateTime createTime){
        return select(dsl -> dsl
                .where(DeptDynamicSqlSupport.createTime,isEqualTo(createTime))
        );
    }

    default Mono<Integer> deleteByDeptNo(Long deptNo){
        return delete(dsl -> dsl
                .where(DeptDynamicSqlSupport.deptNo,isEqualTo(deptNo))
        );
    }

    default Mono<Integer> updateByDeptNo(Dept dept){
        return updateAllByPrimaryKey(dept);
    }

    Flux<DeptWithEmp> selectDeptWithEmpList();
}